package com.vieewer.btdemo.wifimain;

import android.app.Activity;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Bundle;
import android.widget.MediaController;
import android.widget.VideoView;
import com.vieewer.btdemo.R;

public class VideoActivity extends Activity {

    VideoView videoView;
    private MediaController mc;
    Uri vedioUrl;
    @Override
    protected void onCreate(@androidx.annotation.Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_vedio);
        videoView=findViewById(R.id.vedio);
        mc = new MediaController(VideoActivity.this);
        vedioUrl=Uri.parse("android.resource://"+getPackageName()+"/"+R.raw.testvedio);
//        vedioUrl=Uri.parse("file:///android_asset/testvedio.mp4");
        videoView.setVideoURI(vedioUrl);
        videoView.setMediaController(mc);
        videoView.requestFocus();
        videoView.start();
        videoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
            @Override
            public void onCompletion(MediaPlayer mediaPlayer) {
                videoView.start();
            }
        });
    }
}
